
@extends ('layouts/app')

@section('content')

    <div class="weui-cells__title">请绑定持卡人本人银行卡</div>
    <form action="" id="info">
        <div class="weui-cells weui-cells_radio">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">持卡人姓名:</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="account_user">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">银行卡号:</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="account_number">
                </div>
            </div>
            {{--<div class="weui-cell">--}}
                {{--<div class="weui-cell__hd"><label class="weui-label">预留手机号:</label></div>--}}
                {{--<div class="weui-cell__bd">--}}
                    {{--<input class="weui-input" name="mobile"  >--}}
                {{--</div>--}}
            {{--</div>--}}

            <div class="weui-cell weui-cell_select">
                <div class="weui-cell__bd">
                    <select class="weui-select" name="bank">
                        <option selected="" value="招商银行">招商银行</option>
                        <option value="中国工商银行">中国工商银行</option>
                        <option value="中国农业银行">中国农业银行</option>
                        <option value="中国建设银行">中国建设银行</option>
                        <option value="中国交通银行">中国交通银行</option>
                        <option value="中国银行">中国银行</option>
                        <option value="邮政储蓄">邮政储蓄</option>
                    </select>
                </div>
            </div>

        </div>

        <div class="weui-cells__title">掌里通智能加密,保证你的用卡安全,
            <a href="" class="qq-blue">了解安全保障</a>
        </div>


        <div class="weui-btn-area">
            <a href="javascript:;" class="weui-btn weui-btn_primary_a btn-confirm">确定</a>
        </div>
    </form>
    <script>
        $(".btn-confirm").click(function () {
            //声明变量对应需要的判断
            var account_user = $("input[name='account_user']").val(),
                account_number = $("input[name='account_number']").val(),
                bank = $ ("select[name='bank']").val();

            // 姓名不能为空
            var name = InputStrategy.check("isUserName", account_user);
            console.log("name", name);
            if (name) {
                return $.toast(name, "text");
            }
            //https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=6236683320009149980&cardBinCheck=true
            // 验证银行卡号
            var info = InputStrategy.check("isBank", account_number);

            if (info) {
                return $.toast(info, "text");
            }

            if (!bank) {
                return $.toast("所属银行不能为空", "text");
            }
            save('/api/shop/addCard', '#info', function (res) {
                console.log("res", res);
                if (res.code == 200) {
                    history.go(-1);
                }
            });
        });



        $.ajax({
            url: "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=6212262102003764141&cardBinCheck=true",
            type: "get",
            cache: false,
            dataType: "jsonp",
            jsonp: "callback", //这里定义了callback的参数名称，以便服务获取callback的函数名即getMessage
            jsonpCallback: "getBank", //这里定义了jsonp的回调函数
            success: function (data) {
                alert("success:" + data);
            },
            fail: function (f) {
                console.log("f", f);
            },
            error: function (err) {
                console.log("err", err);
            }
        });
//var url = 'https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=6212262102003764141&cardBinCheck=true';
//        $.ajax(url, {
//            data: {
//                'cityname': '成都',
//                'date': '2016.12.12'
//            },
//            dataType: 'jsonp',
//            crossDomain: true,
//            success: function (data) {
//               console.log("data", data);
//            },
//            error: function (err){
//                     console.log("err", err);
//            }
//        });
    </script>
@endsection

